package cn.edu.nwsuaf.examcenter.pojo;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Sclass entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "sclass", catalog = "exam")
public class Sclass implements java.io.Serializable {

	// Fields

	private String classNo;
	private Grade grade;
	private String className;
	private Set<CourceEmployee> courceEmployees = new HashSet<CourceEmployee>(0);
	private Set<Student> students = new HashSet<Student>(0);

	// Constructors

	/** default constructor */
	public Sclass() {
	}

	/** minimal constructor */
	public Sclass(String classNo, Grade grade, String className) {
		this.classNo = classNo;
		this.grade = grade;
		this.className = className;
	}

	/** full constructor */
	public Sclass(String classNo, Grade grade, String className,
			Set<CourceEmployee> courceEmployees, Set<Student> students) {
		this.classNo = classNo;
		this.grade = grade;
		this.className = className;
		this.courceEmployees = courceEmployees;
		this.students = students;
	}

	// Property accessors
	@Id
	@Column(name = "class_no", unique = true, nullable = false, length = 50)
	public String getClassNo() {
		return this.classNo;
	}

	public void setClassNo(String classNo) {
		this.classNo = classNo;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "grade_no", nullable = false)
	public Grade getGrade() {
		return this.grade;
	}

	public void setGrade(Grade grade) {
		this.grade = grade;
	}

	@Column(name = "class_name", nullable = false, length = 50)
	public String getClassName() {
		return this.className;
	}

	public void setClassName(String className) {
		this.className = className;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "sclass")
	public Set<CourceEmployee> getCourceEmployees() {
		return this.courceEmployees;
	}

	public void setCourceEmployees(Set<CourceEmployee> courceEmployees) {
		this.courceEmployees = courceEmployees;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "sclass")
	public Set<Student> getStudents() {
		return this.students;
	}

	public void setStudents(Set<Student> students) {
		this.students = students;
	}

}